package org.mark.sell.feign;

import org.mark.common.entity.FreshFood;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class StorageFreshFoodFeignClientFallback implements StorageFreshFoodFeignClient {
    
    private static final Logger logger = LoggerFactory.getLogger(StorageFreshFoodFeignClientFallback.class);
    
    @Override
    public FreshFood getById(Integer id) {
        logger.error("调用 mark-storage 服务失败，触发服务降级，id: {}", id);
        // 创建一个默认的 FreshFood 对象作为降级响应
        FreshFood fallbackFood = new FreshFood();
        fallbackFood.setId(id);
        fallbackFood.setName("服务暂时不可用");
        fallbackFood.setPrice(0.0);
        logger.info("返回降级数据: {}", fallbackFood);
        return fallbackFood;
    }
} 